using System;

namespace Project.Library.Core
{
    public delegate void BusinessServiceError(object sender, Exception exception);
    public delegate void BusinessServiceStart(object sender, Exception exception);
    public delegate void BusinessServiceEnd(object sender, Exception exception);

    public abstract class AbstractBusinessService : Disposable, IAbstractBusinessService
    {
        #region Events
        
        /// <summary>
        /// Occurs when [business error].
        /// </summary>
        public event BusinessServiceError businessError;

        /// <summary>
        /// Occurs when [remove].
        /// </summary>
        public event BusinessServiceStart businessStart;

        /// <summary>
        /// Occurs when [business end].
        /// </summary>
        public event BusinessServiceEnd businessEnd;

        /// <summary>
        /// Called when [business error].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="exception">The exception.</param>
        public void OnBusinessError(object sender, Exception exception)
        {
            if (businessError != null)
                businessError(sender, exception);
        }

        /// <summary>
        /// Called when [business service start].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="exception">The exception.</param>
        public void OnBusinessServiceStart(object sender, Exception exception)
        {
            if (businessStart != null)
                businessStart(sender, exception);
        }

        /// <summary>
        /// Called when [business service end].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="exception">The exception.</param>
        public void OnBusinessServiceEnd(object sender, Exception exception)
        {
            if (businessEnd != null)
                businessEnd(sender, exception);
        }

        #endregion
    }
}